package com.yunji.coupon.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.coupon.dao.ICouponSiteDao;
import com.yunji.coupon.doamin.CouponSiteDO;
import com.yunji.coupon.mapper.ICouponSiteMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/10/24 11:13
 * @description : TODO
 **/
@Repository
public class CouponSiteDaoImpl extends BaseDaoImpl<ICouponSiteMapper, CouponSiteDO> implements ICouponSiteDao {
    @Override
    public List<CouponSiteDO> listByTmplId(Long tmplId) {
        return lambdaQuery().eq(CouponSiteDO::getCouponTmplId, tmplId).list();
    }

    @Override
    public List<CouponSiteDO> getAvailableSites(Long siteId, List<Long> tmplIdList) {
        return lambdaQuery().eq(CouponSiteDO::getSiteId, siteId).in(CouponSiteDO::getCouponTmplId, tmplIdList).list();
    }

    @Override
    public List<CouponSiteDO> getAvailableSites(Long siteId, Long tmplId) {
        return lambdaQuery().eq(CouponSiteDO::getSiteId, siteId).in(CouponSiteDO::getCouponTmplId, tmplId).list();
    }

    @Override
    public void removeByTmpId(Long tmplId) {
        super.remove(new LambdaQueryWrapper<CouponSiteDO>().eq(CouponSiteDO::getCouponTmplId, tmplId));
    }
}
